package diamond.day02;

public class ThreadDemo {
    public static void main(String[] args) {
        Thread thread3 = new Thread3();
        thread3.start();
        for(int i = 0;i<100;i++){
            System.out.println("学生们在吃饭");
            if(i==5){
                try {
                    thread3.join();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }
    };
}

// 打印偶数
class Thread1 extends Thread{
    @Override
    public void run() {
        for(int i=0;i<100;i++){
            if(i%2==0){
                System.out.println(Thread.currentThread()+":"+i);
            }
        }
    }
}

// 打印基数
class Thread2 extends Thread{
    @Override
    public void run() {
        for(int i=0;i<100;i++){
            if(i%2!=0){
                System.out.println(Thread.currentThread()+":"+i);
            }
        }
    }
}

class Thread3 extends Thread{
    @Override
    public void run() {
        for(int i = 0;i<100;i++){
            System.out.println("习大大来吃饭了："+i);
        }
    }
}
